// pages/tabList/tabList.js
const app = getApp()
var postLogin = require("../../utils/wh.js");
var WxParse = require('../../wxParse/wxParse.js');
Page({
  data: {
    enterprise: [],
    latitude: '',
    longitude: '',
    title: "测试",
    markers: [{
      id: 1,
      latitude: '',
      longitude: '',
      commpany_name: "",//公司名称
    }],

    infos: [],
    limit_num: 6,//每頁數量
    idxpage: 1,//第幾頁
    honor: [], // 企业荣誉
    // tab切换  
    currentTab: 0,
    // 人才招聘
    list: [],//人才招聘列表,
    scroll_top: 0,
  },
 
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.showLoading({
      title: '加载中•••',
      // mask: true
    })
    postLogin.Post('/api/company.index/job', {}, that.recruitment);//人才招聘
  },
  onShow: function (options) {
   
  },

  recruitment: function (res) {
    let that = this;
    for (var i = 0, len = res.length; i < len; ++i) {
      res[i]['open_status'] = false;
      res[i]['select_status'] = false;
    }
    /**
    * WxParse.wxParse(bindName , type, data, target,imagePadding)
    * 1.bindName绑定的数据名(必填)
    * 2.type可以为html或者md(必填)
    * 3.data为传入的具体数据(必填)
    * 4.target为Page对象,一般为this(必填)
    * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选)
    */
    for (let j = 0; j < res.length; j++) {
      WxParse.wxParse('reply' + j, 'html', res[j].job_content, that)
      if (j === res.length - 1) {
        WxParse.wxParseNewArray("list", 'reply', res.length, that, res)
      }
    }
    wx.hideLoading();
  },
  // 人才招聘展开收起
  kindToggle: function (e) {
    var id = e.currentTarget.id;//当前id
    var list = this.data.list;
    for (var i = 0, len = list.length; i < len; ++i) {
      if (list[i].job_id == id) {
        list[i].open_status = !list[i].open_status,
          list[i].select_status = !list[i].select_status
      } else {
        list[i].open_status = false,
          list[i].select_status = false
      }
    }
    // list[id].open_status = !list[id].open_status
    this.setData({
      list: list,
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function (res) {
    var that = this;
    if (res.from === 'button') {
    }
    return {
      title: '人才招聘',
      path: 'pages/aboutus/aboutus?id=3',
      success: function () {
        // console.log('我是'+that.data.currentTab)
      },
      fail: function () {
        // 转发失败
      }
    }
  }
})